﻿using UnityEngine;
using System;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;

[Constructable]					// can be instantiated, or else will have to use the static version
public class AutomatedFactory : Building, IConstructable
{
	private double m_TurnCounter;				// for IConstructable

	#region IConstructable
	public double TurnCounter
	{
		get { return m_TurnCounter; }
		set { m_TurnCounter = value; }
	}
	#endregion

	public AutomatedFactory()
	{
		this.Name = GameEnums.Facilities.AutomatedFactory;
		this.DispName = Utility.SplitName(this.Name.ToString());
		this.MotherTech = new GameEnums.TechName[] { GameEnums.TechName.AutomatedFactories };
	}
	
	public AutomatedFactory(bool getID) : this()
	{
		FacilityID = ++Galaxy.FacilitySerial;
		Core.Buildings.Add(FacilityID, this);
	}

	public AutomatedFactory(Planet pl)
	{
		Planet = pl;
	}

	public override void OnTurn()
	{
		base.OnTurn();

		Planet.Kingdom.SciPower += Planet.Population[0] * 1;

		Planet.DevPower += Planet.Population[1] * 1;			// dev population
		Planet.ProdPower += Planet.Population[1] / 3;

		Planet.FarmPower += Planet.Population[2] * 1;

		// consume gold on each turn
		Planet.Kingdom.Gold -= 1;
	}

	public override void OnTurn(Planet pl)
	{
		base.OnTurn(pl);

		Planet = pl;
		this.OnTurn();
	}

	public override void OnBuilt()
	{
		base.OnBuilt();

		Planet.BaseProd += 3;
		Planet.BaseDev += 5;
	}

	public override void OnBuilt(Planet pl)
	{
		base.OnBuilt(pl);

		Planet = pl;
		this.OnBuilt();
	}
}